package com.molichuxing.services.infrastructure.service.impl;

import com.molichuxing.services.infrastructure.bean.VehicleBean;
import com.molichuxing.services.infrastructure.bean.VehicleModleBean;
import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.VehicleModleMapper;
import com.molichuxing.services.infrastructure.dto.response.VehicleDto;
import com.molichuxing.services.infrastructure.dto.response.VehicleModleDto;
import com.molichuxing.services.infrastructure.service.VehicleModleService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 车系 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-07-29
 */
@Service("vehicleModleService")
public class VehicleModleServiceImpl implements VehicleModleService {

  @Resource
  private VehicleModleMapper vehicleModleMapper;

  @Override
  public VehicleModleDto getVehicleModleDtoById(Integer vehicleModleId) {
    //根据颜色id 查询颜色
     VehicleModleBean vehicleModleBean = vehicleModleMapper.getById(vehicleModleId);
    return  Convert.toVehicleModleDto(vehicleModleBean);
  }

  @Override
  public List<VehicleModleDto> getVehicleModleDtoByIds(List<Integer> vehicleModleIds) {
    if(null == vehicleModleIds || vehicleModleIds.size() == 0) {
      return null;
    }
    List<VehicleModleDto> result = new ArrayList<>();
    for(Integer vehicleModleId : vehicleModleIds) {
      VehicleModleBean vehicleModleBean = vehicleModleMapper.getById(vehicleModleId);
      result.add(Convert.toVehicleModleDto(vehicleModleBean));
    }
    return result;
  }

  @Override
  public List<VehicleModleDto> getVehicleModleList(Integer vehicleMakeId) {
    return Convert.toVehicleModleDto(vehicleModleMapper.getVehicleModleList(vehicleMakeId));
  }

  @Override
  public List<VehicleModleDto> getVehicleModleListAndVehicle(Integer vehicleMakeId, List<Integer> vehicleIds) {
    return Convert.toVehicleModleDto(vehicleModleMapper.getVehicleModleListAndVehicle(vehicleMakeId,vehicleIds));
  }
}
